package com.tcc.fastline.Helpers;

import com.tcc.fastline.Domain.TipoUsuario;
import com.tcc.fastline.Menu.MenuChain;
import com.tcc.fastline.Menu.Implementations.MenuEstabelecimentoFila;
import com.tcc.fastline.Menu.Implementations.MenuEstabelecimentoHome;
import com.tcc.fastline.Menu.Implementations.MenuEstabelecimentoLogout;
import com.tcc.fastline.Menu.Implementations.MenuEstabelecimentoPerfil;
import com.tcc.fastline.Menu.Implementations.MenuEstabelecimentoRelatorio;
import com.tcc.fastline.Menu.Implementations.MenuUsuarioEntrarFila;
import com.tcc.fastline.Menu.Implementations.MenuUsuarioHome;
import com.tcc.fastline.Menu.Implementations.MenuUsuarioLogout;
import com.tcc.fastline.Menu.Implementations.MenuUsuarioMinhaFila;
import com.tcc.fastline.Menu.Implementations.MenuUsuarioPerfil;
import com.tcc.fastline.Menu.Implementations.MenuUsuarioPesquisarRestaurantes;
import com.tcc.smartqueue.R;

import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;

public class MenuHelper {

	static MenuChain chain;

	public static void IniciarMenu(String tipoUser) {
		if (tipoUser.equals("Estabelecimento")) {
			CarregarChainEstabelecimentos();
		} 
		else if (tipoUser.equals("Usuario")) {
			CarregarChainUsuario();
		}
	}

	public static void ExibirMenu(MenuInflater inflater, String tipoUser,
			Menu menu) {
		if (tipoUser.equals("Estabelecimento")) {
			inflater.inflate(R.menu.restaurante_menu, menu);
			CarregarChainEstabelecimentos();
		} else if (tipoUser.equals("Usuario")) {
			inflater.inflate(R.menu.usuario_menu, menu);
			CarregarChainUsuario();
		} else {
			inflater.inflate(R.menu.login, menu);
		}
	}

	public static void NavegarMenu(String option) {
		try {
			chain.navegar(option.toString());
		} catch (Exception e) {
			throw new RuntimeException(e.getMessage());
		}

	}

	private static void CarregarChainUsuario() {
		chain = new MenuUsuarioHome();
		chain.setNext(new MenuUsuarioMinhaFila());
		chain.setNext(new MenuUsuarioEntrarFila());
		chain.setNext(new MenuUsuarioPerfil());
		chain.setNext(new MenuUsuarioPesquisarRestaurantes());
		chain.setNext(new MenuUsuarioLogout());
	}

	private static void CarregarChainEstabelecimentos() {

		chain = new MenuEstabelecimentoHome();
		chain.setNext(new MenuEstabelecimentoPerfil());
		chain.setNext(new MenuEstabelecimentoFila());
		chain.setNext(new MenuEstabelecimentoRelatorio());
		chain.setNext(new MenuEstabelecimentoLogout());

	}
}
